package objetosficheros;

import java.io.*;
import java.util.*;

public class ObjetosFicheros {

    public static void main(String[] args) throws ClassNotFoundException {

        Scanner sc=new Scanner(System.in);
        
        File f=new File("cuentas.data");
        
        
        ObjectOutputStream out=null;
        ObjectInputStream in=null;
        System.out.println("Ha petau");
        
        try {
            out=new ObjectOutputStream(new FileOutputStream(f));
            out.writeObject(new Cuenta("Pepe",2100));
            out.close();
            
            in=new ObjectInputStream(new FileInputStream(f));
            Cuenta c=(Cuenta)in.readObject();
            System.out.println(c.toString());
            
        } catch (FileNotFoundException ex) {
            System.out.println("Fichero no encontrado");
        } catch (IOException ex){
            System.out.println("Error de escritura " + ex.getMessage());
        }
        
    }

}
